package com.hanock.sm.fork2d;

public class ScaleTransform extends Transform {

	private float scaleFrom;
	private float scaleTo;
	private int timeFrom;
	private int timeTo;
	
	
	public ScaleTransform(float scaleFrom, float scaleTo, int timeFrom, int timeTo) {
		
		this.scaleFrom = scaleFrom;
		this.scaleTo = scaleTo;
		this.timeFrom = timeFrom;
		this.timeTo = timeTo;
	}
	
	@Override
	public void progress(Node node, int time) {
		super.progress(node, time);
		
		int act = getActionTime() - timeFrom;
		int interval = timeTo - timeFrom;
		
		if (act < 0 || act > interval)
			return;
		
		float s = scaleFrom + (scaleTo - scaleFrom)*1f*act/interval;
		
		node.setScale(s, s);
	}
	
	@Override
	public boolean isFinished() {
		return getActionTime() > timeTo;
	}

}


















